<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 将层层嵌套的数组扁平为一个数组
      let arr = [
        [1, 2, 2],
        [3, 4, 5, 5],
        [6, 7, 8, 9, [11, 22, [12, 13, [14]]]],
      ];
      let oneArr = arr.flat(Infinity);
      console.log("第一种方法", oneArr);
      let twoArr = arr.join(",");
      twoArr = twoArr.split(",");
      console.log(twoArr);
      twoArr = twoArr.map((val) => parseFloat(val));
      console.log(twoArr);
    </script>
  </body>
</html>
